package com.jpa.demo.bean;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.GenericGenerator;

/**
 * <p>Title:Product</p>
 * <p>Description:</p>
 * @company sinobest 
 * @author Administrator
 * @date 2016年10月9日 上午1:19:56
 * 
 */
@Entity
@Table(name = "t_product")
public class Product implements Serializable {

	/** serialVersionUID*/
	private static final long serialVersionUID = -9085061276998575564L;

	public Product() {
		super();
	}
	
	public Product(String name, String price, String descripton) {
		super();
		this.name = name;
		this.price = price;
		this.descripton = descripton;
	}

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name = "id", unique = true, nullable = false)
	private Integer id;

	@Column(name = "name", length = 500)
	private String name;
	@Column(name = "price", length = 10)
	private String price;
	@Column(name = "descripton", length = 500)
	private String descripton;
	// 延迟加载：多对一方式
	// 关联信息：外键name = "category_id"
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "category_id")
	private Category category;
	
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getPrice() {
		return price;
	}
	public void setPrice(String price) {
		this.price = price;
	}
	public String getDescripton() {
		return descripton;
	}
	public void setDescripton(String descripton) {
		this.descripton = descripton;
	}
	public Category getCategory() {
		return category;
	}
	public void setCategory(Category category) {
		this.category = category;
	}
}
